<% include ../header %>
<%if(result){%>
<div class="alert alert-success">冲值成功</div>
<%}%>
<h2>为【<%=user.name%>】充值</h2>
<p>当前账户余额：￥<%=parseFloat(user.balance||0).toFixed(2)%>元</p>
<br>
<form action="" method="post">
  <input type="hidden" name="user_id" value="<%=user._id%>">
  <input type="hidden" name="amount" value="50">
  <span class="btn btn-primary" data-amount="50">充值￥50 元</span>
</form>
<form action="" method="post">
  <input type="hidden" name="user_id" value="<%=user._id%>">
  <input type="hidden" name="amount" value="100">
  <span class="btn btn-primary" data-amount="100">充值￥100 元</span>
</form>
<form action="" method="post">
  <input type="hidden" name="user_id" value="<%=user._id%>">
  <input type="hidden" name="amount" value="200">
  <span class="btn btn-primary" data-amount="200">充值￥200 元</span>
</form>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close cancel" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">充值</h3>
  </div>
  <div class="modal-body">
    <p>确认为【<%=user.name%>】充值￥<span id="amount"></span>元？</p>
  </div>
  <div class="modal-footer">
    <button class="btn btn-primary sure">确定</button>
    <button class="btn btn-danger cancel" data-dismiss="modal" aria-hidden="true">取消</button>
  </div>
</div>
<script type="text/javascript">
  $("form span.btn").live('click', function () {

    var _this = $(this);
    $('#amount').text($(this).attr('data-amount'));

    $('#myModal').modal({
      keyboard: true,
      show: true,
      backdrop: true
    });
    //管理员取消
    $(".cancel").live('click', function () {
      return;
    })
    //管理员确定则执行删除操作
    $(".sure").live('click', function () {
      _this.parent('form').submit();
    })
  });
</script>
<% include ../footer %>